home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / NUMBERS.SWG / 0025_Handling Numbers in ASM.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-27  |  1KB  |  67 lines

  1. { SEAN PALMER
  2.  
  3. I've been playing around with the AAM instruction and came up with some
  4. things you guys might find useful...
  5.  
  6. Strings as function results are WIERD with the inline Assembler. 8)
  7. }
  8.  
  9. function div10(b : byte) : byte; assembler;
  10. asm
  11.   mov al, b
  12.   aam
  13.   mov al, ah
  14. end;
  15.  
  16. function mod10(b : byte) : byte; assembler;
  17. asm
  18.   mov al, b
  19.   aam
  20. end;
  21.  
  22. type
  23.   str2 = string[2];
  24.   str8 = string[8];
  25.  
  26. function toStr2(b : byte) : str2; assembler;
  27. asm {only call with b=0~99}
  28.   les  di, @RESULT
  29.   cld
  30.   mov  al, 2
  31.   stosb
  32.   mov  al, b
  33.   aam
  34.   xchg ah, al
  35.   add  ax, $3030
  36.   stosw
  37. end;
  38.  
  39. {makes date string in MM/DD/YY format from m,d,y}
  40. function toDateStr(m,d,y:byte):str8;assembler;asm {only call with m,d,y=0~99}
  41.   les  di, @RESULT
  42.   cld
  43.   mov  al, 8
  44.   stosb
  45.   mov  al, m
  46.   aam
  47.   xchg ah, al
  48.   add  ax, $3030
  49.   stosw
  50.   mov  al, '/'
  51.   stosb
  52.   mov  al, d
  53.   aam
  54.   xchg ah, al
  55.   add  ax, $3030
  56.   stosw
  57.   mov  al, '/'
  58.   stosb
  59.   mov  al, y
  60.   aam
  61.   xchg ah, al
  62.   add  ax, $3030
  63.   stosw
  64. end;
  65.  
  66.  
  67.